<script type="text/javascript" src="{$base_dir}modules/general_emr/js/AJAX_Eye_Examination.js"></script>
{literal}
<script type="text/javascript">
jQuery(document).ready(function() {
	$('#clinDiagRightTension').blur(function() {
		$('#clinDiagLeftTension').val($(this).val());
	});
	$('#clinDiagRightBPT').blur(function() {
		$('#clinDiagLeftBPT').val($(this).val());
	});
	$('#clinDiagRightBPS').blur(function() {
		$('#clinDiagLeftBPS').val($(this).val());
	});
	$('#rightCVA').blur(function() {
		checkCVA($(this));
	});		
	$('#leftCVA').blur(function() {
		checkCVA($(this));
	});	
	$('#rightUCVA').blur(function() {
		checkCVA($(this));
	});	
	$('#leftUCVA').blur(function() {
		checkCVA($(this));
	});	
	$('#bothEyesight').blur(function() {
		checkCVA($(this));
	});		
});

function checkCVA(obj) {
	var text = $.trim(obj.val());
	text = text.toLowerCase();	
	if (text.match(/^[0-9]+[+|-]?$/)) {
		obj.val(text + '/10');
		return;
	}
	if (text.match(/^d$/)) {
		obj.val({/literal}'{translate}Count fingers{/translate}'{literal});
		return;
	}
	if (text.match(/^[s]+[+]?$/)) {
		obj.val({/literal}'{translate}Light and shade positive{/translate} (+)' {literal});
		return;
	}
	if (text.match(/^[s]-[-]?$/)) {
		obj.val({/literal}'{translate}Sáng tối âm tính{/translate} (-)' {literal});
		return;
	}
	if (text.match(/^b$/)) {
		obj.val({/literal}'{translate}Shadow of hand{/translate}'{literal});
		return;
	}
}
</script>
{/literal}
<div id="clinDiagEdit" style="display: block;">
	<form id="frmClinDiagEdit" action="../EyeExamination/EditEyeExamination" method="post">
		<input type="hidden" name="encounterId" id="encounterId" value="{$encounter->getId()}">
		<input type="hidden" name="recordId" id="recordId" value="{$recordId}">
		<span id="statusMessageClinDiag" class='formAlertMsg'></span><br/>
		
		<table border="0" cellpadding="0" cellspacing="0" style='margin-bottom: 10px;'>
			<tr>
				<td class="label">
		        	{translate}Examination date{/translate}
		      	</td>
		      	<td class="field">
		      		{$createdDate}
		      	</td>
		      	<td class="label">
		      		{translate}Doctor{/translate}
		      	</td>
		      	<td colspan="2" class="field">
		        	{$doctorName}
		        	<input name="doctorId" id="doctorId" type="hidden" value="{$doctorId}">
		      	</td>
		   	</tr>
			<tr>
				<td class="label">
					{translate}Latest update{/translate}
				</td>
				<td class="field">
					{$updatedDate}
				</td>
				<td class="label">
					{translate}Updated by Dr{/translate}
				</td>
				<td colspan="2" class="field">
				  	{$doctorUpdate}
				</td>
			</tr>
		</table>
		
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td class="label">
				 	{translate}Symptom{/translate}
				</td>
				<td colspan="3">
				  	<textarea name="clinDiagSymptom" id="clinDiagSymptom" rows="1" cols="45">{$encounter->getSymptom()}</textarea>
				</td>
			</tr>
			<tr>
				<td class="label">
				   	{translate}Clinical Examination{/translate}
				</td>
				<td align="center" class="label">
				   	{translate}Right eye{/translate}
				</td>
				<td align="center" colspan="2" class="label">
				   	{translate}Left eye{/translate}
				</td>
			</tr>
		    <tr>
				<td colspan="4" align="left" class="label">
					<span>{translate}Vision acuity{/translate}</span>
				</td>
			</tr>
			<tr>
				<td align="right" class="label">
					<i><span>{translate}Without correction{/translate}</span></i>
				</td>
				<td>
					<input name="rightCVA" id="rightCVA" type="text" value="{$commonInfo->getRightCVA()}" size="25"/>
				</td>
				<td colspan="2">
					<input name="leftCVA" id="leftCVA" type="text" value="{$commonInfo->getLeftCVA()}" size="25"/>
				</td>
			</tr>
			<tr>
				<td align="right" class="label">
					<i><span>{translate}With correction{/translate}</span></i>
				</td>
				<td>
					<input name="rightUCVA" id="rightUCVA" type="text" value="{$commonInfo->getRightUCVA()}" size="25"/>
				</td>
				<td colspan="2">
					<input name="leftUCVA" id="leftUCVA" type="text" value="{$commonInfo->getLeftUCVA()}" size="25"/>
				</td>
			</tr>
			<tr>
				<td align="left" class="label">
					<span>{translate}Biocular vision{/translate}</span>
				</td>
				<td colspan='3'>
					<input name="bothEyesight" id="bothEyesight" type="text" value="{$commonInfo->getBothEyesight()}" size="25"/>
				</td>
			</tr>
			<tr>
				<td align="right" class="label">
				  	<i>{translate}Ocular tension{/translate}</i>
				</td>
				<td align="left">
				   	<input type="text" name="clinDiagRightTension" id="clinDiagRightTension" value="{$encounter->getRightTension()}" align="left" size="25">
				</td>
				<td colspan="2" align="left">
				 	<input type="text" name="clinDiagLeftTension" id="clinDiagLeftTension" value="{$encounter->getLeftTension()}" align="left" size="25">
				</td>
			</tr>
			<tr>
				<td align="right" class="label">
				  	<i>{translate}Fore semi-sphere{/translate}</i>
				</td>
				<td align="left">
				   	<input type="text" name="clinDiagRightBPT" id="clinDiagRightBPT" value="{$encounter->getRightBPT()}" align="left" size="25">
				</td>
				<td colspan="2" align="left">
				  	<input type="text" name="clinDiagLeftBPT" id="clinDiagLeftBPT" value="{$encounter->getLeftBPT()}" align="left" size="25">
				</td>
			</tr>
			<tr>
				<td align="right" class="label">
				   <i>{translate}Back semi-sphere{/translate}</i>
				</td>
				<td align="left">
				  	<input type="text" name="clinDiagRightBPS" id="clinDiagRightBPS" value="{$encounter->getRightBPS()}" align="left" size="25">
				</td>
				<td colspan="2" align="left">
				    <input type="text" name="clinDiagLeftBPS" id="clinDiagLeftBPS" value="{$encounter->getLeftBPS()}" align="left" size="25">
				</td>
			</tr>
			<tr>
				<td valign="top" class="label">
					{translate}Diagnosis{/translate} (*)
				</td>
				<td colspan="3">
					<textarea name="chandoan" id="chandoan" rows="1" cols="45">{$encounter->getChanDoan()}</textarea>
				</td>
			</tr> 
			<tr>
				<td valign="top" class="label">
				    {translate}ICD diagnosis{/translate} (*)
				</td>
				<td colspan="3">
					<input type="text" name="clinDiagPrimaryIcd10" id="clinDiagPrimaryIcd10" value="{$priIcd10->getCode()}" align="left" size="10">
					<input type="text" name="clinDiagPrimaryDiagnosis" id="clinDiagPrimaryDiagnosis" value="{$priIcd10->getLocalizedText('name')}" align="left" size="45">
					<button type="button" id="btnPriIcd10">...</button>
				</td>
			</tr>
		{if ($enableSecondary)}
			<tr>
				<td valign="top" class="label">
				   	{translate p='1'}Auxiliary diagnosis %s{/translate} 
				</td>
				<td colspan="3">
				    <input type="text" name="clinDiagSecondaryIcd10_1" id="clinDiagSecondaryIcd10_1" value="{$sec1Icd10->getCode()}" align="left" size="10">
				    <input type="text" name="clinDiagSecondaryDiagnosis_1" id="clinDiagSecondaryDiagnosis_1" value="{$sec1Icd10->getLocalizedText('name')}" align="left" size="45">
				    <button type="button" id="btnSecIcd10_1">...</button>
				</td>
			</tr>
			<tr>
				<td valign="top" class="label">
				   	{translate p='2'}Auxiliary diagnosis %s{/translate}
				</td>
				<td colspan="3">
					<input type="text" name="clinDiagSecondaryIcd10_2" id="clinDiagSecondaryIcd10_2" value="{$sec2Icd10->getCode()}" align="left" size="10">    
					<input type="text" name="clinDiagSecondaryDiagnosis_2" id="clinDiagSecondaryDiagnosis_2" value="{$sec2Icd10->getLocalizedText('name')}" align="left" size="45">
					<button type="button" id="btnSecIcd10_2">...</button>
				</td>
			</tr>
		{/if}
			<tr>
				<td valign="top" class="label">
					{translate}Note{/translate}
				</td>
				<td colspan="3">
				   	<textarea name="clinDiagNote" id="clinDiagNote" rows="1" cols="45">{$encounter->getNote()}</textarea>
				</td>
			</tr>
			<tr>
				<td class="label">
				   	{translate}Indication{/translate} (*)
				</td>
				<td colspan="3">
				   	<select name="clinDiagTreatment" id="clinDiagTreatment">
				   		{html_options options=$encounter->getEncounterTreatmentList() selected=$encounter->getTreatment()}
				   	</select>
				</td>
			</tr>
		   	<tr>
		   		<td>&nbsp;</td>
		   		<td class="label" colspan="3">
		   			<input type="checkbox" name="potentialPhaco"
		   				{if $patient->get('potential_for') == 'phaco'}checked="checked"{/if}> &nbsp;&nbsp;{translate}Phaco Potential{/translate}
		   		</td>
		   	</tr>
		   	<tr>
			   	<td align="left">
					<a id="btnSave" class="button_link" href="javascript:submitForm()">{translate}Save{/translate}</a>
					<div id="divEditMessageBarLoading" style="display:none;" align="center">
						<img src="{$base_uri}/images/ajax-loader.gif"/>
					</div>
			   	</td>
			   	<td colspan='3' align='left'>
			   		<div id='lblEditMessage' style='font-style: italic'></div>
			   	</td>
		   	</tr>
		</table>
	</form>
	{include file="icd_10/element_icd10_selector.html"}
</div>